package algorithm.tree;

/**
 * 二叉链表结点
 * @param <E>
 */
public class BinaryNode<E> {
    public E data;
    public BinaryNode<E> left,right;

    public BinaryNode(E data, BinaryNode left, BinaryNode right) {
        this.data = data;
        this.left = left;
        this.right = right;
    }

    public BinaryNode(E data) {
        this(data,null,null);
    }

    public BinaryNode() {
        this(null,null,null);
    }
    //判断是否是叶子节点
    public boolean isLeaf() {
        return this.left == null && this.right == null;
    }

    @Override
    public String toString() {
        return "BinaryNode{" +
                "data=" + data +
                ", left=" + left +
                ", right=" + right +
                '}';
    }
}
